package top.likeqc.leetcode.editor.cn;

/** 链接: https://leetcode.cn/problems/minimum-changes-to-make-alternating-binary-string */
public class MinimumChangesToMakeAlternatingBinaryString {
    public static void main(String[] args) {
        Solution solution = new MinimumChangesToMakeAlternatingBinaryString().new Solution();
    }
    // leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int minOperations(String s) {
            char c = '0';
            int t = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) != c) {
                    t++;
                }
                c = (c == '0' ? '1' : '0');
            }

            return Math.min(t, s.length() - t);
        }
    }
    // leetcode submit region end(Prohibit modification and deletion)

}
